package com.example.springboot.globalutils;

/**
 * 统一异常处理
 */
public class BizException extends RuntimeException {
    private static final long serialVersionUID = 1L;
    private RespCodeEnums respCodeEnum;
    private String msg;
    private int code = 500;

    public BizException(String msg) {
        super(msg);
        this.msg = msg;
    }

    public BizException(String msg, Throwable e) {
        super(msg, e);
        this.msg = msg;
    }

    public BizException(String msg, int code) {
        super(msg);
        this.msg = msg;
        this.code = code;
    }

    public BizException(String msg, int code, Throwable e) {
        super(msg, e);
        this.msg = msg;
        this.code = code;
    }

    public BizException(int code, String msg) {
        super(msg);
        this.msg = msg;
        this.code = code;
    }

   /* public BizException(BaseErrorInfoInterface errorInfoInterface) {
        super(errorInfoInterface.getResultMsg());
        this.msg = errorInfoInterface.getResultMsg();
        this.code = errorInfoInterface.getResultCode();
    }*/

    public BizException(RespCodeEnums respCodeEnum) {
        super(respCodeEnum.getDesc());
        this.respCodeEnum = respCodeEnum;
        this.msg = respCodeEnum.getDesc();
        this.code = respCodeEnum.getCode();
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
